//
//  WJIndexThreeTableViewCell.m
//  天气
//
//  Created by dllo on 16/8/23.
//  Copyright © 2016年 WJ. All rights reserved.
//

#import "WJIndexThreeTableViewCell.h"
#import "WJThreeCollectionViewCell.h"
#import "WJTitleLable.h"
#define kWJWidth  [UIScreen mainScreen].bounds.size.width
#define kWJHeight [UIScreen mainScreen].bounds.size.height

@interface WJIndexThreeTableViewCell ()<UICollectionViewDelegate,UICollectionViewDataSource>

@end


@implementation WJIndexThreeTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0.35];
        [self createView];
        
    }
    return self;
}

- (void)createView
{
    WJTitleLable *contentLabel = [[WJTitleLable alloc]initWithFrame:CGRectMake(20, 0, kWJWidth - 40, 30)];
    contentLabel.text = @"生活指数";
    contentLabel.textAlignment = 0;
    [self.contentView addSubview:contentLabel];
    
    
    
    // 创建 flowLayout
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    flowLayout.itemSize = CGSizeMake(kWJWidth / 2 , 70);
    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
    flowLayout.minimumLineSpacing = 0;
    flowLayout.minimumInteritemSpacing = 0;
    
    // 创建CollectiobView
    self.collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 50, kWJWidth, 280) collectionViewLayout:flowLayout];
    [self.contentView addSubview:self.collectionView ];
    self.collectionView .backgroundColor = [UIColor clearColor];
    self.collectionView .delegate = self;
    self.collectionView .dataSource = self;
    self.collectionView.bounces = NO;
    /* 注册cell的重用池 */
    [self.collectionView  registerClass:[WJThreeCollectionViewCell class] forCellWithReuseIdentifier:@"WJThreeCollectionViewCell"];
    
}
//item的个数(方块的个数)
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return 8;
}

//cell的样式(可以自定义)
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    WJThreeCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"WJThreeCollectionViewCell" forIndexPath:indexPath];
    
    switch (indexPath.row) {
        case 0:
            cell.picView.image = [UIImage imageNamed:@"ic_lifeindex_sport"];
            cell.typeLabel.text = @"运动";
            cell.label.text = self.life[@"info"][@"yundong"][0];
            break;
            
        case 1:
            cell.picView.image = [UIImage imageNamed:@"ic_lifeindex_ultravioletrays"];
            cell.typeLabel.text = @"紫外线";
            cell.label.text = self.life[@"info"][@"ziwaixian"][0];
            break;

        case 2:
            cell.picView.image = [UIImage imageNamed:@"ic_lifeindex_coldl"];
            cell.typeLabel.text = @"感冒";
            cell.label.text = self.life[@"info"][@"ganmao"][0];
            break;

        case 3:
            cell.picView.image = [UIImage imageNamed:@"ic_lifeindex_carwash"];
            cell.typeLabel.text = @"洗车";
            cell.label.text = self.life[@"info"][@"xiche"][0];
            break;

        case 4:
            cell.picView.image = [UIImage imageNamed:@"ic_lifeindex_tour"];
            cell.typeLabel.text = @"旅游";
            cell.label.text = self.life[@"info"][@"wuran"][0];
            break;

        case 5:
            cell.picView.image = [UIImage imageNamed:@"ic_lifeindex_dress"];
            cell.typeLabel.text = @"穿衣";
            cell.label.text = self.life[@"info"][@"chuanyi"][0];
            break;

        case 6:
            cell.picView.image = [UIImage imageNamed:@"ic_lifeindex_city"];
            cell.typeLabel.text = @"空调";
            cell.label.text = self.life[@"info"][@"kongtiao"][0];
            break;

        case 7:
            cell.picView.image = [UIImage imageNamed:@"ic_lifeindex_calendar"];
            cell.typeLabel.text = @"黄历";
            cell.label.text = self.life[@"date"];
            break;

        default:
            break;
    }
    
    
    return cell;
}











@end
